<template>
    <view class="global-components-wrap">
        <u-toast ref="toast" />
        <!-- <u-top-tips ref="tips"></u-top-tips> -->
        <auth-login ref="auth"></auth-login>
        <u-no-network></u-no-network>
        <loading ref="loading" :show="loading" @close="closeLoadingEvent"></loading>
    </view>
</template>

<script>
/**
 * global-components 全局组件
 * @description 本组件集合一些页面通用组件为一个全局组件不必在页面添加额外标签
 * @param {Boolean} loading 是否显示loading
 * @event closeLoadingEvent loading关闭事件
 * @function toast 显示toast提示
 * @function tips 显示tips提示
 * @function openLoading 开启loading
 * @function closeLoading 关闭loading
 */
export default {
    name: "GlobalComponents",
    props: {
        // 是否显示loading
        loading: { type: Boolean, default: true }
    },
    data() {
        return {};
    },
    computed: {},
    methods: {
        showAuth(){
          this.$refs.auth.show();  
        },
        // 显示toast提示
        toast(option){
            this.$refs['toast'].show(option);
        },
        // 显示tips提示
        tips(option){
            this.$refs['tips'].show(option);
        },
        // 开启loading
        openLoading() {
            this.$refs["loading"].open();
        },
        // 关闭loading
        closeLoading() {
            this.$refs["loading"].close();
        },
        // loading关闭事件
        closeLoadingEvent(){
            this.$emit('closeLoading');
        }
    },
    mounted() {}
};
</script>
